<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1"/>
    <title>FORTRAN.io - Controller</title>
    <link rel="stylesheet" type="text/css" href="/static/bootstrap.min.css"/>
  </head>
  <body>
    <div class="container">
      <div class="row">
        <div class="col-sm-12">
          <div class="page-header">
            <h1>
              <a href="/">FORTRAN.io</a>
              <small>finally, a Fortran Web Framework</small>
            </h1>
          </div>
        </div>
      </div>
      <div class="row">
        <div class="navbar navbar-default">
          <ul class="nav navbar-nav">
            <li>
              <a href="/">Home</a>
            </li>
            <li>
              <a href="/static/model.html">Model</a>
            </li>
            <li class="active">
              <a href="/static/view.html">View</a>
            </li>
            <li>
              <a href="/static/controller.html">Controller</a>
            </li>
          </ul>
        </div>
      </div>
      <div class="row">
        <p>The easiest way to serve files is to put them into the static directory.</p>
        <p>For more dynamic and readable layouts, you can use an HTML templating system similar to Jade or HAML:</p>
<pre>
body
  h1 Hello World
  ul.className
    li#one Inside Text
    li#two Inside Text 2
    li
      a(href="http://example.com") Link
</pre>
        <p>You can insert variable names into your template:</p>
<pre>
h4
  span #{name}
  small #{occupation}
</pre>

        <p>Control functions (for / if - else - endif) and container divs should be printed directly in the controller.</p>
        <p>This is also where you pass info to the template engine:</p>
<pre>
! open .container
write(unitNo,AFORMAT) '&lt;div class="container"&gt;'

! use a 2D array for key-value pairs -
pagevars(1,1) = 'name'
pagevars(1,2) = 'Nick'
pagevars(2,1) = 'occupation'
pagevars(2,2) = 'mapmaker'

! use URL variable ?lang=__ to fill in this variable
call cgi_get(dict, 'lang', language)

if (language == 'english') then
  templatefile = 'template/result-english.jade'
else
  templatefile = 'template/result-spanish.jade'
endif
call jadetemplate(templatefile, unitNo, pagevars)

! close .container
write(unitNo,AFORMAT) '&lt;/div&gt;'
</pre>
      </div>
    </div>
  </body>
</html>
